from pymilvus import MilvusClient

# 设置连接参数
HOST = "localhost"  # 或你的 Milvus 服务器 IP
PORT = "19530"      # Milvus 默认端口
db_name = "default" # 数据库名

# 创建客户端连接
client = MilvusClient(uri=f"http://{HOST}:{PORT}", db_name=db_name)
print(client)

# 测试连接（可选）
try:
    # 检查连接状态或执行简单操作
    collections = client.list_collections()
    print("连接成功！")
    print(f"现有集合: {collections}")
except Exception as e:
    print(f"连接失败: {e}")